/**
 * 
 */
package in.smartbillpay.web.services;

import java.util.List;

import in.smartbillpay.web.dao.AuthorityDao;
import in.smartbillpay.web.models.Authority;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ADIMBLE
 *
 */
@Service
@Transactional(readOnly = true)
public class AuthorityServiceImpl implements AuthorityService {
	@Autowired
	private AuthorityDao authorityDao;

	public AuthorityDao getAuthorityDao() {
		return authorityDao;
	}

	public void setAuthorityDao(AuthorityDao authorityDao) {
		this.authorityDao = authorityDao;
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.AuthorityService#getAuthority(int)
	 */
	public Authority getAuthority(int id){
		return getAuthorityDao().getById(id);
	}
	
	
	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.AuthorityService#getAllAuhtorities()
	 */
	public List<Authority> getAllAuhtorities(){
		return getAuthorityDao().getAll();
	}
	
	
	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.AuthorityService#save(in.smartbillpay.web.models.Authority)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public Authority save(Authority authority) {
		
		return getAuthorityDao().save(authority);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.AuthorityService#delete(in.smartbillpay.web.models.Authority)
	 */
	public void delete(Authority authority) {
		getAuthorityDao().delete(authority);
	}

	public List<Authority> getByName(String authorityName) {
		return getAuthorityDao().getByName(authorityName);
	}

	public void delete(int authorityId) {
		getAuthorityDao().delete(getAuthorityDao().getById(authorityId));
		
	}
	
	
}
